package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.card.EntityPackageData;
import com.ocom.common.entity.card.EntityXfSubAccount;
import com.ocom.common.request.callpackage.GetPackagePayResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface IDaoPackageData extends BaseMapper<EntityPackageData> {

    @Select({"<script>",
            "SELECT\n" +
                    "\tpd.com_id,\n" +
                    "\tpd.order_no,\n" +
                    "\tpd.package_type_id,\n" +
                    "\tpt.package_type_name,\n" +
                    "\tpt.day_month,\n" +
                    "\tpt.days_months,\n" +
                    "\tpt.price,\n" +
                    "\tpt.remark,\n" +
                    "\tpd.update_time,\n" +
                    "\tpd.amount,\n" +
                    "\tpd.start_date,\n" +
                    "\tpd.stop_date\n" +
                    " FROM\n" +
                    "\tpackage_data pd\n" +
                    " LEFT JOIN package_type pt ON pd.com_id = pt.com_id\n" +
                    " AND pd.package_type_id = pt.package_type_id\n" +
                    " WHERE\n" +
                    "\tpd.com_id = #{comId}\n" +
                    " AND pd.p_id = #{pId}\n" +
                    "<when test=\"beginDate != null \" >" +
                    " AND pd.update_time &gt;= #{beginDate}\n" +
                    " </when>" +
                    "<when test=\"endDate != null \" >" +
                    " AND pd.update_time &lt; #{endDate}\n" +
                    " </when>" +
                    " ORDER BY\n" +
                    "\tpd.update_time DESC\n" +
                    "<when test=\"size != null and size &gt; 0\" >" +
                    " LIMIT #{size}" +
                    " </when>" +
                    "</script>"})
    List<GetPackagePayResponse> getPackagePay(Long comId, Long pId, Date beginDate, Date endDate, Integer size);

}
